package com.zw.controller.user;

import com.zw.core.domain.AjaxResult;
import com.zw.dto.TemplateDto;
import com.zw.service.TemplateService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 模板接口
 */
@Tag(name = "模板")
@RestController
@RequestMapping("/user/template")
public class TemplateController {

    @Resource
    private TemplateService templateService;

    @Operation(summary = "查询模板列表")
    @GetMapping("/list")
    @PreAuthorize("@ss.authenticated()")
    public AjaxResult templateList(TemplateDto templateDto) {
        return AjaxResult.success(templateService.visibleTemplateList(templateDto));
    }

    @Operation(summary = "查询模板")
    @GetMapping("/{id}")
    @PreAuthorize("@ss.authenticated()")
    public AjaxResult templateColumns(@PathVariable Long id) {
        return AjaxResult.success(templateService.visibleTemplate(id));
    }
}
